/*
 * @lc app=leetcode.cn id=1337 lang=typescript
 *
 * [1337] 矩阵中战斗力最弱的 K 行
 */

// @lc code=start
function kWeakestRows(mat: number[][], k: number): number[] {
    const sorted = [...mat].sort((a, b) => {
        const _a = a.reduce((i, j) => i + j, 0);
        const _b: number = b.reduce((i, j) => i + j, 0);
        return _a - _b;
    });
    return sorted.slice(0, k).map((i) => mat.indexOf(i));
}
// @lc code=end
